package com.kaifamiao.uploader.ex;

import com.kaifamiao.uploader.entity.Resp;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ControllerAdviceHandler {

    @ExceptionHandler(Exception.class)
    public Resp handleException(Exception e) {
        e.printStackTrace();
        if (StringUtils.hasText(e.getMessage())) {
            return Resp.error(e.getMessage());
        }else {
            return Resp.error("服务器异常");
        }
    }
}
